package com.boxandroid.myrom;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MyRom extends Activity implements OnClickListener{
	private GameLife engine;
	
	private Button playGame;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        Util.WINDOW_W = getWindowManager().getDefaultDisplay().getWidth();
        Util.WINDOW_H = getWindowManager().getDefaultDisplay().getHeight();
        setContentView(R.layout.main);
        
        playGame = (Button) findViewById(R.id.btPlay);
        playGame.setOnClickListener(this);
    }
    
    @Override
    public void onDestroy(){
    	super.onDestroy();
    	if(engine != null)
    		if(engine.getThread().isAlive())
    			engine.getThread().interrupt();
    	finish();
    }

	@Override
	public void onClick(View v) {
		if(v.getId() == playGame.getId()){
			engine = new GameLife(this);
			engine.setFocusable(true);
			engine.getThread().doStart();
			setContentView(engine);
		}
	}
}